﻿CREATE PROCEDURE [dbo].[Articles_UpdateSpaces]
	@RangeReviewId int
AS

Update Articles
Set Width = spaces.Width, Facings = spaces.Facings
From Articles a 
Inner Join (
Select ArticleId, Width, SUM(Facings) Facings From Spaces
Group By ArticleId, Width) spaces on a.Id = spaces.ArticleId
Where a.RangeReviewId = @RangeReviewId